# -*- coding: utf-8 -*-

import jsonpath

dic = {
    "resultCode": "1",
    "resultMsg": "success",
    "reqId": "52f9f3e1-1d76-47b4-b2ae-226633b61476",
    "systemTime": "1681991278593",
    "videoInfo": {
        "playSta": "1",
        "video_image": "https://image.pearvideo.com/cont/20170714/cont-1110173-10436784.png",
        "videos": [
            {
                "hdUrl": "1",
                "hdflvUrl": "",
                "sdUrl": "",
                "sdflvUrl": "bbbbbb",
            },
            {
                "hdUrl": "",
                "hdflvUrl": "",
                "sdUrl": "",
                "sdflvUrl": "cccccc",
                "srcUrl": "https://video.pearvideo.com/mp4/short/20170714/-10632788-hd.mp4"
            },
            {
                "hdUrl": "",
                "hdflvUrl": "",
                "sdUrl": "",
                "sdflvUrl": "dddddd",
                "srcUrl": "https://video.pearvideo.com/mp4/short/20170714/1681991278593-10632788-hd.mp4"
            },
        ]
    }
}

# 包含srcUrl的对象， @ 当前节点的子节点
# "hdUrl": "1": 利用jsonpath获取数据， 没有获取到数据 返回False
# 注意: 1不等'1'
# print(jsonpath.jsonpath(dic, '$..videos[?(@.hdUrl=="1")]'))

# 多个子节点，通过下标取对应的节点值
# print(jsonpath.jsonpath(dic, '$..videos[0].sdflvUrl'))

# *： 去所有节点的sdflvUrl  注意: 获取下来的数据 放在一个列表当中
print(jsonpath.jsonpath(dic, '$..videos[*].sdflvUrl'))














# print(jsonpath.jsonpath(dic,'$..videos')) # 赋值给一个变量 第一个列表通过下标0取出他里面值 在通过循环第二个列表取出里面的字典

# print(jsonpath.jsonpath(dic))

# print(jsonpath.jsonpath(dic, '$..videos[?(@.srcUrl=="https://video.pearvideo.com/mp4/short/20170714/1681991278593-10632788-hd.mp4")]'))




